unit libPublicImportDllU;

interface

uses
  Windows, libPublicInterfaceU, Sysutils;

var
  hPublicFunction: THandle;


implementation

procedure doIni;
var
  PublicFunInterface: function: IPublicFunction; stdcall;
begin
  hPublicFunction := LoadLibrary('PublicFunction.dll');
  try
    if hPublicFunction <> 0 then
    begin
      @PublicFunInterface := GetProcAddress(hPublicFunction, 'PublicFunction');
      libPublicInterfaceU.PublicFunction := PublicFunInterface;
    end;
  finally
    PublicFunInterface := nil;
  end;
end;


procedure doFinial;
begin
  libPublicInterfaceU.PublicFunction := nil;

  if hPublicFunction <> 0 then
  try
    FreeLibrary(hPublicFunction);
  except
  end;

end;


initialization
  doIni;
finalization
  doFinial;
end.
